package com.mingtu.jgspatrol.adapter;

import androidx.annotation.NonNull;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.mingtu.common.utils.MyUtills;
import com.mingtu.jgspatrol.R;
import com.mingtu.jgspatrol.bean.ParkAuditBean;

public class ParkReserveAdapter extends BaseQuickAdapter<ParkAuditBean.PageBean.ListBean, BaseViewHolder> {

    public ParkReserveAdapter() {
        super(R.layout.item_reserve_info);
    }

    @Override
    protected void convert(@NonNull BaseViewHolder helper, ParkAuditBean.PageBean.ListBean dataBean) {
        String date = dataBean.getReservationDate(); //预约日期
        String parkName = dataBean.getParkName(); //预约地点
        String reason = dataBean.getReason();   //事由
        int vehicle = dataBean.getVehicle(); //交通方式 1：步行 2：自驾
        String plateNo = dataBean.getPlateNo(); //车牌号
        String owner = dataBean.getOwner(); //预约人
        String phoneNo = dataBean.getPhoneNo(); //预约人电话

        try {
            helper.setText(R.id.tv_date, MyUtills.convertDateFormat(date));
            helper.setText(R.id.tv_address, parkName);
            helper.setText(R.id.tv_reason, reason);
            if (vehicle == 1) {
                helper.setText(R.id.tv_traffic, "步行");
                helper.setGone(R.id.layout_car_number, false);
            } else if (vehicle == 2) {
                helper.setText(R.id.tv_traffic, "自驾");
                helper.setText(R.id.tv_car_number, plateNo);
                helper.setGone(R.id.layout_car_number, true);
            }
            helper.setText(R.id.tv_name, owner);
            helper.setText(R.id.tv_tel, phoneNo);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }

    }


}
